<?php
/**
 * Author Yulin
 * Email  dwzhanglong@126.com
 * Date   2017-9-19
 * Func   新疆11选5
 */
defined('IN_YuLin') || exit('NO PERMIT!');

//	返回中奖金额	data为订单信息，plays为玩法

function PrizeCount_20($data,$plays)
{
	global $db;
	
	if(!$data || !$data['result'] || !$plays)
	{
		return 0;
	}
	
	//	玩法
	$result = explode(',',$data['result']);
	
	//	投注号
	$data['rednum'] = str_replace('_','|',$data['rednum']);
	
	//	前四、后四、前三、中三、后三、前二、后二
	$qiansi = [$result[0],$result[1],$result[2],$result[3]];
	$housi = [$result[1],$result[2],$result[3],$result[4]];
	$qiansan = [$result[0],$result[1],$result[2]];
	$housan = [$result[2],$result[3],$result[4]];
	$zhongsan = [$result[1],$result[2],$result[3]];
	$qianer = [$result[0],$result[1]];
	$houer = [$result[3],$result[4]];
	
	//	前三直选复式
	if($plays['playid'] == 21044)
	{
		//	重号不可以中奖（因为投注的时候不会投注重号）
		$tmp = array_count_values($qiansan);
		if(count($tmp) < 3)
		{
			return 0;
		}
		
		$tmp = explode('|',$data['rednum']);
		$tmp[0] = explode(',',$tmp[0]);
		$tmp[1] = explode(',',$tmp[1]);
		$tmp[2] = explode(',',$tmp[2]);
		
		return in_array($result[0],$tmp[0]) && in_array($result[1],$tmp[1]) && in_array($result[2],$tmp[2]) ? $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	前三直选单式
	if($plays['playid'] == 21045)
	{
		$tmp = implode(',',$qiansan);
		
		return in_array($tmp,explode('|',$data['rednum'])) ? $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	前三组选复式
	if($plays['playid'] == 21046)
	{
		$tmp = explode('|',$data['rednum']);
		
		return in_array($result[0],$tmp) && in_array($result[1],$tmp) && in_array($result[2],$tmp) ? $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	前三组选单式
	if($plays['playid'] == 21047)
	{
		$tmp2 = $qiansan;
		sort($tmp2);
		
		$tmp3 = 0;
		$tmp = explode('|',$data['rednum']);
		foreach($tmp as $t)
		{
			$t = explode(',',$t);
			sort($t);
			
			$t == $tmp2 && $tmp3++;
		}
		
		return $tmp3 ? $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	前二直选复式
	if($plays['playid'] == 21048)
	{
		//	不能出现对子
		if($result[0] == $result[1])
		{
			return 0;
		}
		
		$tmp = explode('|',$data['rednum']);
		$tmp[0] = explode(',',$tmp[0]);
		$tmp[1] = explode(',',$tmp[1]);
		
		return in_array($result[0],$tmp[0]) && in_array($result[1],$tmp[1]) ? $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	前二直选单式
	if($plays['playid'] == 21049)
	{
		//	不能出现对子
		if($result[0] == $result[1])
		{
			return 0;
		}
		
		$tmp2 = implode(',',$qianer);		
		$tmp3 = 0;
		$tmp = explode('|',$data['rednum']);
		foreach($tmp as $t)
		{
			$t == $tmp2 && $tmp3++;
		}
		
		return $tmp3 ? $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	前二组选复式
	if($plays['playid'] == 21050)
	{
		//	不能出现对子
		if($result[0] == $result[1])
		{
			return 0;
		}
		
		$tmp = explode('|',$data['rednum']);
		
		return in_array($result[0],$tmp) && in_array($result[1],$tmp) ? $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	前二组选单式
	if($plays['playid'] == 21051)
	{
		//	不能出现对子
		if($result[0] == $result[1])
		{
			return 0;
		}
		
		$tmp1 = $result[0].','.$result[1];
		$tmp2 = $result[1].','.$result[0];
		$tmp = explode('|',$data['rednum']);
		
		return in_array($tmp1,$tmp) && in_array($tmp2,$tmp) ? $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	不定胆前三
	if($plays['playid'] == 21052)
	{
		$tmp3 = 0;
		$tmp = explode('|',$data['rednum']);
		foreach($tmp as $t)
		{
			in_array($t,$qiansan) && $tmp3++;
		}
		
		return $tmp3 * $plays['maxprize'] * $data['times'];
	}
	
	//	定位胆
	if($plays['parentid'] == 1449)
	{
		$tmp = explode('|',$data['rednum']);
		if($plays['playid'] == 21053)
		{
			return in_array($result[0],$tmp) ? $plays['maxprize'] * $data['times'] : 0;
		}
		if($plays['playid'] == 21317)
		{
			return in_array($result[1],$tmp) ? $plays['maxprize'] * $data['times'] : 0;
		}
		if($plays['playid'] == 21318)
		{
			return in_array($result[2],$tmp) ? $plays['maxprize'] * $data['times'] : 0;
		}
		if($plays['playid'] == 21319)
		{
			return in_array($result[3],$tmp) ? $plays['maxprize'] * $data['times'] : 0;
		}
		if($plays['playid'] == 21320)
		{
			return in_array($result[4],$tmp) ? $plays['maxprize'] * $data['times'] : 0;
		}
		
		return 0;
	}
	
	//	单双
	$dan = 0;
	foreach($result as $t)
	{
		$t % 2 && $dan++;
	}
	if($plays['playid'] == 21054)
	{
		return $dan == 5 ? $plays['maxprize'] * $data['times'] : 0;
	}
	if($plays['playid'] == 21321)
	{
		return $dan == 0 ? $plays['maxprize'] * $data['times'] : 0;
	}
	if($plays['playid'] == 21322)
	{
		return $dan == 1 ? $plays['maxprize'] * $data['times'] : 0;
	}
	if($plays['playid'] == 21323)
	{
		return $dan == 4 ? $plays['maxprize'] * $data['times'] : 0;
	}
	if($plays['playid'] == 21324)
	{
		return $dan == 2 ? $plays['maxprize'] * $data['times'] : 0;
	}
	if($plays['playid'] == 21325)
	{
		return $dan == 3 ? $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	猜中位
	if($plays['parentid'] == 1451)
	{
		$tmp = $result;
		sort($tmp);
		
		return $data['rednum'] == $tmp[2] ? $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	一中一
	if($plays['playid'] == 21056)
	{
		$tmp3 = 0;
		$tmp = explode('|',$data['rednum']);
		foreach($tmp as $t)
		{
			in_array($t,$result) && $tmp3++;
		}
		
		return $tmp3 * $plays['maxprize'] * $data['times'];
	}
	
	//	二中二
	if($plays['playid'] == 21057)
	{
		$tmp3 = 0;
		$tmp = explode('|',$data['rednum']);
		foreach($tmp as $t)
		{
			$t = explode(',',$t);
			in_array($t[0],$result) && in_array($t[1],$result) && $tmp3++;
		}
		
		return $tmp3 * $plays['maxprize'] * $data['times'];
	}
	
	//	三中三
	if($plays['playid'] == 21058)
	{
		$tmp3 = 0;
		$tmp = explode('|',$data['rednum']);
		foreach($tmp as $t)
		{
			$t = explode(',',$t);
			in_array($t[0],$result) && in_array($t[1],$result) && in_array($t[2],$result) && $tmp3++;
		}
		
		return $tmp3 * $plays['maxprize'] * $data['times'];
	}
	
	//	四中四
	if($plays['playid'] == 21059)
	{
		$tmp3 = 0;
		$tmp = explode('|',$data['rednum']);
		foreach($tmp as $t)
		{
			$t = explode(',',$t);
			in_array($t[0],$result) && in_array($t[1],$result) && in_array($t[2],$result) && in_array($t[3],$result) && $tmp3++;
		}
		
		return $tmp3 * $plays['maxprize'] * $data['times'];
	}
	
	//	五中五
	if($plays['playid'] == 21060)
	{
		$tmp3 = 0;
		$tmp = explode('|',$data['rednum']);
		foreach($tmp as $t)
		{
			$t = explode(',',$t);
			in_array($t[0],$result) && in_array($t[1],$result) && in_array($t[2],$result) && in_array($t[3],$result) && in_array($t[4],$result) && $tmp3++;
		}
		
		return $tmp3 * $plays['maxprize'] * $data['times'];
	}
	
	//	六中五
	if($plays['playid'] == 21061)
	{
		//	出现重复号码就中不了，投注不可以投重复号码
		$tmp = array_count_values($result);
		if(count($tmp) < 5)
		{
			return 0;
		}
		
		$tmp3 = 0;
		$tmp = explode('|',$data['rednum']);
		foreach($tmp as $t)
		{
			$t = explode(',',$t);
			in_array($result[0],$t) && in_array($result[1],$t) && in_array($result[2],$t) && in_array($result[3],$t) && in_array($result[4],$t) && $tmp3++;
		}
		
		return $tmp3 * $plays['maxprize'] * $data['times'];
	}
	
	//	七中五
	if($plays['playid'] == 21062)
	{
		//	出现重复号码就中不了，投注不可以投重复号码
		$tmp = array_count_values($result);
		if(count($tmp) < 5)
		{
			return 0;
		}
		
		$tmp3 = 0;
		$tmp = explode('|',$data['rednum']);
		foreach($tmp as $t)
		{
			$t = explode(',',$t);
			in_array($result[0],$t) && in_array($result[1],$t) && in_array($result[2],$t) && in_array($result[3],$t) && in_array($result[4],$t) && $tmp3++;
		}
		
		return $tmp3 * $plays['maxprize'] * $data['times'];
	}
	
	//	八中五
	if($plays['playid'] == 21063)
	{
		//	出现重复号码就中不了，投注不可以投重复号码
		$tmp = array_count_values($result);
		if(count($tmp) < 5)
		{
			return 0;
		}
		
		$tmp3 = 0;
		$tmp = explode('|',$data['rednum']);
		foreach($tmp as $t)
		{
			$t = explode(',',$t);
			in_array($result[0],$t) && in_array($result[1],$t) && in_array($result[2],$t) && in_array($result[3],$t) && in_array($result[4],$t) && $tmp3++;
		}
		
		return $tmp3 * $plays['maxprize'] * $data['times'];
	}
	
	//	任选一中一
	if($plays['playid'] == 21064)
	{
		$tmp3 = 0;
		$tmp = explode('|',$data['rednum']);
		foreach($tmp as $t)
		{
			in_array($t,$result) && $tmp3++;
		}
		
		return $tmp3 * $plays['maxprize'] * $data['times'];
	}
	
	//	任选二中二
	if($plays['playid'] == 21065)
	{
		$tmp3 = 0;
		$tmp = explode('|',$data['rednum']);
		foreach($tmp as $t)
		{
			in_array($t,$result) && $tmp3++;
		}
		
		return $tmp3 > 1 ? NumGroup($tmp3,2) * $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	任选三中三
	if($plays['playid'] == 21066)
	{
		$tmp3 = 0;
		$tmp = explode('|',$data['rednum']);
		foreach($tmp as $t)
		{
			in_array($t,$result) && $tmp3++;
		}
		
		return $tmp3 > 2 ? NumGroup($tmp3,3) * $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	任选四中四
	if($plays['playid'] == 21067)
	{
		$tmp3 = 0;
		$tmp = explode('|',$data['rednum']);
		foreach($tmp as $t)
		{
			in_array($t,$result) && $tmp3++;
		}
		
		return $tmp3 > 3 ? NumGroup($tmp3,4) * $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	任选五中五
	if($plays['playid'] == 21068)
	{
		$tmp3 = 0;
		$tmp = explode('|',$data['rednum']);
		foreach($tmp as $t)
		{
			in_array($t,$result) && $tmp3++;
		}
		
		return $tmp3 > 4 ? $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	任选六中五
	if($plays['playid'] == 21069)
	{
		$tmp3 = 0;
		$tmp = explode('|',$data['rednum']);
		foreach($tmp as $t)
		{
			in_array($t,$result) && $tmp3++;
		}
		
		return $tmp3 > 4 ? $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	任选七中五
	if($plays['playid'] == 21070)
	{
		$tmp3 = 0;
		$tmp = explode('|',$data['rednum']);
		foreach($tmp as $t)
		{
			in_array($t,$result) && $tmp3++;
		}
		
		return $tmp3 > 4 ? $plays['maxprize'] * $data['times'] : 0;
	}
	
	//	任选八中五
	if($plays['playid'] == 21071)
	{
		$tmp3 = 0;
		$tmp = explode('|',$data['rednum']);
		foreach($tmp as $t)
		{
			in_array($t,$result) && $tmp3++;
		}
		
		return $tmp3 > 4 ? $plays['maxprize'] * $data['times'] : 0;
	}
	
	return 0;
}